{extend name='public/content'}

{block name="title"}
	订单详情
{/block}

{block name="body"}
<div ng-app="myApp" ng-controller="myCtrl"> 	
	<div class="layui-container">  
	  <div class="layui-row">
	    <div class="layui-col-xs4 layui-col-sm12 layui-col-md4">
	    	 
	    	 <div class="layui-row" ng-repeat="(k, v) in data.orderdetaile">
			    <div class="layui-col-xs4 layui-col-sm12 layui-col-md4">
					<img ng-src="{{v.goods.logo}}" style="width:80px;height: 70px">
			    </div>
			    <div class="layui-col-xs4 layui-col-sm12 layui-col-md4">
					名称：{{v.goods.name}}
					总价：{{v.final_amount}}
			    </div>
			    <div class="layui-col-xs4 layui-col-sm12 layui-col-md4">
					{{v.spec_detail}}
			    </div>
			    <div class="pingjia layui-btn layui-btn-normal" data-orderid="{{v.id}}"
			    	 data-id="{{v.goods_id}}" data-storid="{{v.storeid}}" ng-click="pnjia(v)">评价
			    </div>
	   		 </div>

	  	</div>
	  </div>
			<div class="layui-container">最终价格：{{data.order.final_amount}}</div>
	</div>
	
</div>
{/block}

{block name="script"}
<script type="text/javascript">
 	require(['jquery',"angular"], function () {
 			angular.module('myApp', [])
			.service('$factory',function($http){
				var locg={
		   			order:function($id,call){
		   				var url ="{:url('order/orderdetailapi')}?id="+$id;
	                 	$http.get(url,{}).then(function(res){call(res)})	
		   			},
		   			pinglun:function(data,call){
		   				var url ="{:url('order/pinglun')}";
	                 	$http.post(url,data).then(function(res){call(res)})	
		   			}	
		   		}
		   		return locg;
			})
			.controller('myCtrl', function($scope, $http,$factory) {
				var $id = "{$id}";

				$factory.order($id,function(data){
					$scope.data=data.data;
					console.log($scope.order);
				
				})
				$scope.pnjia=function(x){
					console.log(x);
					layer.prompt({
 						 formType: 2,
 						  value: '',
						  title: '请输入评价类容',
						  area: ['500px', '250px']},
		  				function(value, index, elem){
		 				 layer.close(index);
		 				 let  goodsid= x.id;
		 				 let  store_id= x.storeid;
		 				 let  order_id= $scope.data.order.id; 
		 				 let data = {
		 				 	goodsid:goodsid,
		 				 	msg:value,
		 				 	store_id:store_id,
		 				 	order_id:order_id
		 				 }
	 					 $factory.pinglun(data,function(res){
	 					 		console.log(res);
	 					 })
						}
					)
				}
				
			})
			.filter('trustHtml', function ($sce) {
		        return function (input) {
		            return $sce.trustAsHtml(input);
		        }
		    });


 		/*$(".pingjia").click(function(event) {
 			var	 that =this;
 			layer.prompt({
 						 formType: 2,
 						  value: '',
						  title: '请输入评价类容',
						  area: ['500px', '250px']},
  				function(value, index, elem){
 				 layer.close(index);
 				 var  goodsid= $(that).data('id');
 				 var  storid= $(that).data('storid');
 				 var  orderid= $(that).data('orderid'); 				 
 				$.ajax({
 					url: "{:url('order/pinglun')}",
 					type: 'POST',
 					dataType: 'json',
 					data: {id:goodsid,msg:value,store_id:storid,order_id:orderid},
 				})
 				.done(function() {
 					
 				})
 				.fail(function() {
 					console.log("error");
 				})
 				.always(function() {
 					console.log("complete");
 				});
 				
			});
 		});*/
 	})
 </script>
{/block}

{block name="style"}
 <style type="text/css">
 	
 </style>
{/block}